package com.leapp.sk.viewdelegate.personal

import android.content.Context
import android.text.TextUtils
import android.widget.TextView
import com.example.mvp.delegate.BaseAppDelegate
import com.example.mvp.view.NoScrollGridView
import com.example.mvp.view.SKTopBar
import com.leapp.sk.R
import com.leapp.sk.bean.FeedBackDetialEntity
import com.leapp.sk.ui.activity.personal.FeedBackDetialActicity
import com.leapp.sk.ui.activity.personal.FeedbackActivity
import com.leapp.sk.ui.adapter.FeedBackDetialImageAdapter

/**
 * 反馈详情
 * @author  chaohaipeng  on 2018/8/9.
 */
class FeedBackDetialDelegate :BaseAppDelegate(){
    override fun initWidget() {
    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_feed_back_detial
    }

    /**
     * 初始化图片适配器
     */
    fun initImageAdapter(context: Context, mlist: List<String>){
        val gv_afbd_image = getView<NoScrollGridView>(R.id.gv_afbd_image)
        val feedBackDetialImageAdapter = FeedBackDetialImageAdapter(context, mlist)
        gv_afbd_image.adapter=feedBackDetialImageAdapter

    }

    /**
     * 设置数据
     */
    fun setData(data: FeedBackDetialEntity){
        val tv_afbd_detial_title = getView<TextView>(R.id.tv_afbd_detial_title)
        val tv_afbd_detial_content = getView<TextView>(R.id.tv_afbd_detial_content)
        tv_afbd_detial_title.text=data.title
        tv_afbd_detial_content.text=data.content
    }


    /**
     * 设置标题栏
     */
    fun setTitle(title:String?){
        val jtb_afbd= getView<SKTopBar>(R.id.jtb_afbd)
        if (!TextUtils.isEmpty(title)){
            jtb_afbd.setTitle(title)
        }
        setEvent(jtb_afbd)
    }

    /**
     * 设置设置事件
     */
    fun setEvent(topBar: SKTopBar){
        topBar?.setEventInterface(object : SKTopBar.EventInterface{
            override fun leftOnClick() {
                getActivity<FeedBackDetialActicity>().finish()

            }
            override fun rightOnClick() {
            }

        })
    }

}